
<!-- News -->
<div class="news">
    <div class="row">
        <div class="col-lg-6 in-gp-tb">
            <div class="input-group">
                <input type="text" class="form-control" name="todo" placeholder="ToDo...">
                <span class="input-group-btn">
                    <button class="btn btn-default add" type="button">Add!</button>
                </span>
            </div><!-- /input-group -->
            <div class="alert alert-danger" id="error_alert" style="display: none;" role="alert"></div>
        </div><!-- /.col-lg-6 -->
    </div><!-- /.row -->
    <div class="container">
        <div class="latest-news">
            <h3>ToDo List</h3>
            <div class="event-grids">

                {foreach $list as $value}
                <div class="event-grid event-grid-1">
                    <div class="event-image">
                        <p class="date-1">{:date('H:i',$value['add_time'])}</p>
                        <p class="date-3">{:date('y/m/d',$value['add_time'])}</p>
                    </div>
                    <div class="event-info">
                        <p>{$value['content']}</p>
                        <!--<h5>{$value['id']}</h5>-->
                        <h4>&nbsp;{if condition="!empty($value['end_time'])"}EndTime:{:date('d m Y',$value['end_time'])}{/if}</h4>
                    </div>
                    <div class="clearfix"></div>
                </div>
                {/foreach}
                <div class="clearfix"></div>
            </div>
        </div>
        <div class="clearfix"></div>
    </div>
</div>
<!-- //News -->
<script type="text/javascript">
    var sub_url = '{:url("ext/todo/add")}';
    $(function(){
        $('.add').click(function(){
            var content = $('input[name="todo"]').val();
            if(content == ''){
                return;
            }else{
                $.post(sub_url,{'content':content},function(data){
                    if(data.code == 1){
                        window.location.href = "{:url('ext/todo/index')}";
                    }else{
                        $('#error_alert').html('<strong>添加失败!</strong>&nbsp;' + data.msg);
                        $('#error_alert').show();
                    }
                });
            }
        });
    })
</script>